<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/inc/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="decorator" content="main" />
<style type="text/css">
.textbox {
	height: 20px;
	margin: 0;
	padding: 0 2px;
	box-sizing: content-box;
}
</style>
<script type="text/javascript">
	$(document).ready(function() {
		query();
	});

	function query() {
		hasPowerOrNot();
		$('#dg').datagrid({
			url : '${ctx}/column/columnadmin.do?method=load',
			title : '栏目列表',
			pagination : true,
			rownumbers : true,
			fitColumns : true,
			showFooter : true,
			striped : true,
			toolbar : '#tbtopbar',
			queryParams : {
				searchword : $("input[name='searchbox']").val(),
			},
			columns : [ [ {
				field : 'id',
				title : '操作',
				checkbox : true,
			}, {
				field : 'name',
				title : '栏目名称',
				sortable : true,
				width : 100,
			}, {
				field : 'alias',
				title : '栏目简称',
				width : 100,
			}, {
				field : 'type',
				title : '栏目类型',
				width : 100,
			}, {
				field : 'desciption',
				title : '栏目描述',
				width : 100,
			}, {
				field : 'logo',
				title : '栏目图标',
				width : 100,
			}, {
				field : 'kw',
				title : '栏目关键字',
				width : 100,
			}, {
				field : 'seodesc',
				title : 'SEO描述',
				width : 100,
			}, {
				field : 'seotitle',
				title : 'SEO题目',
				width : 100,
			}, {
				field : 'status',
				title : '栏目可用',
				sortable : true,
				width : 100,
			} ] ]
		});
	}

	function hasPowerOrNot() {
		$("#admintb").hide();

		<c:forEach var="menu" items="${sessionScope.menu}">
		<c:set value="${menu.list}" var ="list" />
		<c:if test="${menu.menuIno.menuId==4}">
		<c:forEach var="items" items="${menu.list}">
		console.debug("${items.menuId}");
		<c:if test="${items.menuId==13}">
		console.debug("${items.menuName}");
		$("#admintb").show();
		</c:if>
		</c:forEach>
		</c:if>
		</c:forEach>

	}

	function colFormFix() {
		var info = ($('#dg').datagrid('getSelections'));
		if (info.length == 0) {
			alert("请选择具体栏目进行修改");
		} else if (info.length > 1) {
			alert("您选择了" + info.length + "数据，请选择一条数据进行修改");
		} else {
			var columnid = info[0].id;
			var url = '${ctx}/column/columnadmin.do?method=initForm&columnid=';
			if (!isNaN(columnid)) {
				url += columnid;
			} else {
				url += 0;
			}
			window.location.href = url;
		}
	}

	function colFormAdd() {
		var url = '${ctx}/column/columnadmin.do?method=addForm';
		window.location.href = url;
	}

	function delInfo() {
		var url = '${ctx}/column/columnadmin.do';
		var info = ($('#dg').datagrid('getSelections'));
		var ids = [];
		for ( var i = 0; i < info.length; i++) {
			ids.push(info[i].id);
			console.log(info[i].id);
		}
		;
		$.messager.confirm('确认', '您确认想要删除' + ids.length + '记录吗？', function(r) {
			if (r) {
				$.ajax({
					type : "POST",
					url : url,
					data : 'method=del&columnids=' + ids,
					success : function(dto) {
						$.messager.alert('警告', dto.msg);
						$('#dg').datagrid("reload");
					}
				});
			}
		});
	}
</script>
<title>栏目管理</title>
</head>
<body>
	<ul class="breadcrumbs">
		<li><a href="${ctx}/login/LoginIndexRequestServlet.do"><i
				class="iconfa-home"></i></a> <span class="separator"></span></li>
		<li>栏目管理</li>
	</ul>
	<div class="maincontent">
		<div class="maincontentinner">
			<div class="row-fluid">
				<div class="span12">
					<div class="widget">
						<h4 class="widgettitle">栏目管理</h4>
						<div class="widgetcontent">
							<form id="qryFrom">
								<div id="tbtopbar" style="padding: 5px;">
									<div id="admintb" style="margin-bottom: 5px;">
										<a herf="#" class="easyui-linkbutton" iconCls="icon-add"
											plain="true" onclick="colFormAdd()" id="addbut">添加栏目</a> <a
											herf="#" class="easyui-linkbutton" iconCls="icon-remove"
											plain="true" onclick="delInfo()" id="delbut">删除栏目</a> <a
											herf="#" class="easyui-linkbutton" iconCls="icon-edit"
											plain="true" onclick="colFormFix()" id="fixbut">修改栏目</a>
									</div>
									<div id="usertb" style="padding: 0 0 5px 5px">
										<input class="textbox" name="searchbox"></input> 创建时间从：<input
											class="easyui-datebox" name="date_from"> 到：<input
											class="easyui-datebox" name="date_to"> <a herf="#"
											class="easyui-linkbutton" iconCls="icon-search" plain="true"
											onclick="query()">查询栏目</a>

									</div>
								</div>
							</form>
							<div id="load">
								<input type="hidden" name="method" value="load" />
							</div>
							<table id="dg"></table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div></div>
</body>
</html>